package model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

@Entity
@Table(name = "HoaDon")
public class HoaDon {
	private int id_HoaDon;
	private String ngayHoaDon;
	private String soDienThoai;
	private String diaChi;
	// private boolean xacNhan;
	// private boolean ketThuc;
	// private String thongBaoMuaHang;
	private float tongTien;
	// private Set<Sach> sach = new HashSet<Sach>(0);
	private NguoiDung nguoiDung;
	private String tenNguoiDung;

	// public HoaDon(int id_HoaDon, Date ngayHoaDon, String soDienThoai,
	// String diaChi, boolean xacNhan, boolean ketThuc, String thongBaoMuaHang,
	// float tongTien, Set<Sach> sach, NguoiDung nguoiDung) {
	// super();
	// this.id_HoaDon = id_HoaDon;
	// this.ngayHoaDon = ngayHoaDon;
	// this.soDienThoai = soDienThoai;
	// this.diaChi = diaChi;
	// this.xacNhan = xacNhan;
	// this.ketThuc = ketThuc;
	// this.thongBaoMuaHang = thongBaoMuaHang;
	// this.tongTien = tongTien;
	// this.sach = sach;
	// this.nguoiDung = nguoiDung;
	// }

	public HoaDon(String ngayHoaDon, String soDienThoai, String diaChi,
			float tongTien, String tenNguoiDung) {
		super();
		this.ngayHoaDon = ngayHoaDon;
		this.soDienThoai = soDienThoai;
		this.diaChi = diaChi;
		this.tongTien = tongTien;
		this.nguoiDung = nguoiDung;
		this.tenNguoiDung = tenNguoiDung;
	}

	public HoaDon() {

	}

	@Id
	@GeneratedValue(generator = "HoaDon_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "HoaDon_ID_Gen", sequenceName = "HoaDon_SEQ_ID")
	@Column(name = "ID_HoaDon", unique = true, updatable = false)
	public int getId_HoaDon() {
		return id_HoaDon;
	}

	public void setId_HoaDon(int id_HoaDon) {
		this.id_HoaDon = id_HoaDon;
	}

	@Column(name = "NgayHoaDon", nullable = false)
	public String getNgayHoaDon() {
		return ngayHoaDon;
	}

	public void setNgayHoaDon(String ngayHoaDon) {
		this.ngayHoaDon = ngayHoaDon;
	}

	@Column(name = "SoDienThoai", nullable = false)
	public String getSoDienThoai() {
		return soDienThoai;
	}

	public void setSoDienThoai(String soDienThoai) {
		this.soDienThoai = soDienThoai;
	}

	@Column(name = "DiaChi", nullable = false)
	public String getDiaChi() {
		return diaChi;
	}

	public void setDiaChi(String diaChi) {
		this.diaChi = diaChi;
	}

	// @Column(name = "XacNhan", nullable = false)
	// @Type(type="yes_no")
	// public boolean isXacNhan() {
	// return xacNhan;
	// }
	//
	// public void setXacNhan(boolean xacNhan) {
	// this.xacNhan = xacNhan;
	// }
	//
	// @Column(name = "KetThuc", nullable = false)
	// @Type(type="yes_no")
	// public boolean isKetThuc() {
	// return ketThuc;
	// }
	//
	// public void setKetThuc(boolean ketThuc) {
	// this.ketThuc = ketThuc;
	// }
	//
	// @Column(name = "ThongBaoMuaHang", nullable = false)
	// public String getThongBaoMuaHang() {
	// return thongBaoMuaHang;
	// }
	//
	// public void setThongBaoMuaHang(String thongBaoMuaHang) {
	// this.thongBaoMuaHang = thongBaoMuaHang;
	// }

	@Column(name = "TongTien", nullable = false)
	public float getTongTien() {
		return tongTien;
	}

	public void setTongTien(float tongTien) {
		this.tongTien = tongTien;
	}

	// @ManyToMany
	// @JoinTable(name = "ChiTietHoaDon_Sach", joinColumns = @JoinColumn(name =
	// "ID_HoaDon"), inverseJoinColumns = @JoinColumn(name = "ID_Sach"))
	// public Set<Sach> getSach() {
	// return sach;
	// }
	//
	// public void setSach(Set<Sach> sach) {
	// this.sach = sach;
	// }

	@ManyToOne
	@JoinColumn(name = "ID_NguoiDung")
	public NguoiDung getNguoiDung() {
		return nguoiDung;
	}

	public void setNguoiDung(NguoiDung nguoiDung) {
		this.nguoiDung = nguoiDung;
	}

	@Column(name = "TenNguoiDung")
	public String getTenNguoiDung() {
		return tenNguoiDung;
	}

	public void setTenNguoiDung(String tenNguoiDung) {
		this.tenNguoiDung = tenNguoiDung;
	}

}
